package com.cloud.fullgc;

public class FullGCExample {
    public static void main(String[] args) throws InterruptedException {
        // 打印 JVM 参数：用于查看堆内存设置
        System.out.println("Initial heap size: " + Runtime.getRuntime().totalMemory());
        System.out.println("Maximum heap size: " + Runtime.getRuntime().maxMemory());

        // 模拟内存占用：反复创建对象
        for (int i = 0; i < 100000; i++) {
            byte[] buffer = new byte[1024 * 1024]; // 1MB
        }

        // 强制进行垃圾回收
        System.gc();
        
        // 暂停，等待 GC 执行完
        Thread.sleep(1000);
    }
}
